/**
 * 
 */
package japavo.gui.general_ui;

import japavo.gui.MainFrame;
import japavo.trainer.VocabularyTrainer;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 *
 */
@SuppressWarnings ("serial")
public class MenuBar extends JMenuBar{

	/**********************************************************************************************
	 ************************************ DECLARATIONS ******************************************** 
	 *********************************************************************************************/
	private VocabularyTrainer trainer;
	private MainFrame mainFrame;
	
	/**********************************************************************************************
	 ************************************ CONSTRUCTORS ******************************************** 
	 *********************************************************************************************/
	/**
	 * 
	 */
	public MenuBar(MainFrame mainFrame, VocabularyTrainer trainer) {
		this.trainer = trainer;
		this.mainFrame = mainFrame;
		
		JMenu menu;
		JMenuItem menuItem;
		
		// ========== Vocabulary Menu ==========
		menu = new JMenu(System.getProperty("MENU_VOCABULARY"));
		// NEW
		menuItem = new JMenuItem(System.getProperty("MENU_VOCABULARY_NEW"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.newVocabularyBook();
			}
		});
		menu.add(menuItem);

		// OPEN
		menuItem = new JMenuItem(System.getProperty("MENU_VOCABULARY_OPEN"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.openVocabularyBook();
			}
		});
		menu.add(menuItem);
		
		// EDIT
		menuItem = new JMenuItem(System.getProperty("MENU_VOCABULARY_EDIT"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.editVocabularyBook();
			}
		});
		menu.add(menuItem);
		
		// SAVE
		menuItem = new JMenuItem(System.getProperty("MENU_VOCABULARY_SAVE"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.saveVocabularyBook();
			}
		});
		menu.add(menuItem);
		
		// CLOSE
		menuItem = new JMenuItem(System.getProperty("MENU_VOCABULARY_CLOSE"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.closeVocabularyBook();
			}
		});
		menu.add(menuItem);
		
		this.add(menu);
		
		// ========== Training menu ==========
		menu = new JMenu(System.getProperty("MENU_TRAINING"));
		
		// START
		menuItem = new JMenuItem(System.getProperty("MENU_TRAINING_START"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.startTraining();
			}
		});
		menu.add(menuItem);
		
		// STATS
		menuItem = new JMenuItem(System.getProperty("MENU_TRAINING_STATS"));
		menuItem.addActionListener(new AbstractAction() {
			@Override
			public void actionPerformed(ActionEvent e) {
				MenuBar.this.mainFrame.getTrainingStats();
			}
		});
		menu.add(menuItem);
		
		this.add(menu);
		
		// ========== XX ==========
		// menu = new JMenu(System.getProperty("XX"));
		// YY
		// menuItem = new JMenuItem(System.getProperty("YY"));
		// menu.add(menuItem)
		//
		// this.add(menu)
		
	}
	
	/**********************************************************************************************
	 ************************************** FUNCTIONS ********************************************* 
	 *********************************************************************************************/
	
}
